package com.config;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.servlet.support.AbstractDispatcherServletInitializer;


//TODO：Servlet容器配置类
public class ServletContainersInitConfig extends AbstractDispatcherServletInitializer {
    //TODO：创建SpringMvc容器
    protected WebApplicationContext createServletApplicationContext() {
        AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
        ctx.register(SpringMvcConfig.class);    //注册这个配置类等同于加载
        return ctx;
    }

    //TODO：设置哪些请求交给SpringMvc处理
    protected String[] getServletMappings() {
        return new String[]{"/"};
    }

    //TODO：创建Spring容器
    protected WebApplicationContext createRootApplicationContext() {
        return null;
    }
}
